package com.iss.demo.controller;

import com.iss.demo.entity.Order;
import com.iss.demo.entity.ShopCar;
import com.iss.demo.model.MyResponseData;
import com.iss.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("order/")
public class OrderController {

    @Autowired
    private OrderService service;

    @RequestMapping("selectAll")
    public List<Order> selectAll(){
        List<Order> list=service.selectAll();
        return list;
    }

    @RequestMapping("selectAllById")
    public List<Order> selectAllById(Integer u_id){
        return service.selectAllById(u_id);
    }

    @RequestMapping("insertOrder")
    public MyResponseData insertOrder(Order order){
        Integer count=service.insertOrder(order);
        MyResponseData responseData = new MyResponseData();
        responseData.setErrorCode(count);
        return responseData;
    }

    @RequestMapping("deleteOne")
    public MyResponseData deleteOne(Integer o_id){
        service.deleteOne(o_id);
        MyResponseData responseData = new MyResponseData();
        responseData.setErrorCode(0);
        responseData.setStatus("确定成功");
        return responseData;
    }

    @RequestMapping("update")
    public MyResponseData update(Integer o_id){
        service.update(o_id);
        MyResponseData responseData=new MyResponseData();
        responseData.setErrorCode(0);
        responseData.setStatus("确认成功");
        return responseData;
    }

}
